package org.cfd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import java.util.List;
import org.cfd.entity.Carts;
import org.cfd.mapper.CartsMapper;
import org.cfd.service.CartsService;
import org.springframework.stereotype.Service;

/**
 * @author rjs
 * @description 针对表【carts(购物车表)】的数据库操作Service实现
 * @createDate 2023-09-06 14:59:18
 */
@Service
public class CartsServiceImpl extends ServiceImpl<CartsMapper, Carts> implements CartsService {

  @Resource CartsMapper cartsMapper;

  @Override
  public List<Carts> getCartsByUserId(final Integer id) {
    // 使用QueryWrapper构造查询条件
    final QueryWrapper<Carts> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("user_id", id);
    return cartsMapper.selectList(queryWrapper);
  }
}
